package app.controller.goods;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import app.model.goods.GoodsStockRecords;
import app.service.goods.GoodsStockRecordsService;
import app.util.ServletUtil;
import base.JsonResult;
import base.PageInfo;

@Controller
@RequestMapping("/goodsStockRecords")
public class GoodsStockRecordsController {
	
	private Logger logger = Logger.getLogger(GoodsStockRecordsController.class);
	
	@Autowired
	private GoodsStockRecordsService goodsStockRecordsService;
	
	@ResponseBody
	@RequestMapping("/list.do")
	public PageInfo list(PageInfo pageInfo,HttpServletRequest request){
		Map<String, Object> parameterMap = ServletUtil.getParameterMap(request);
		return goodsStockRecordsService.list(pageInfo,parameterMap);
	}
	
	@ResponseBody
	@RequestMapping("/save.do")
	public JsonResult save(GoodsStockRecords goodsStockRecords){
		if(StringUtils.isEmpty(goodsStockRecords.getId())){
			goodsStockRecordsService.saveEntity(goodsStockRecords);
		}else{
			goodsStockRecordsService.updateEntity(goodsStockRecords);
		}
		return new JsonResult("操作成功");
	}
	
	@ResponseBody
	@RequestMapping("/view.do")
	public JsonResult view(String id){
		GoodsStockRecords goodsStockRecords = goodsStockRecordsService.queryEntityById(id);
		return new JsonResult("操作成功",goodsStockRecords);
	}
	
	@ResponseBody
	@RequestMapping("/del.do")
	public JsonResult del(String ids){
		goodsStockRecordsService.delEntity(ids);
		return new JsonResult("操作成功");
	}
}
